/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package database.create;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

/**
 *
 * @author Administrator
 */
public class CreateMyDatabase {
    public CreateMyDatabase(){
        
        try{
            Class.forName("org.sqlite.JDBC");
            Connection conn =DriverManager.getConnection("jdbc:sqlite:/d:/labdb.db");
            Statement stat = conn.createStatement();
            stat.executeUpdate("drop table if exists gongzuomian;");
            stat.executeUpdate("create table gongzuomian "
                    + "(mingcheng nvarchar(200) unique, "
                    + "zhitu nvarchar(25),"
                    + "zhituriqi nvarchar(50),"
                    + "hedui nvarchar(25),"
                    + "bilichi nvarchar(25),"
                    + "kezhang nvarchar(25),"
                    + "bianhao nvarchar(25),"
                    + "gongchengshi nvarchar(25),"
                    + "caichang nvarchar(200),"
                    + "gzmcd nvarchar(25),"
                    + "gzmzxcd nvarchar(200),"
                    + "gzmgszbx nvarchar(25),"
                    + "gzmgszby nvarchar(25),"
                    + "gzmfwj nvarchar(25),"
                    + "ahcjl nvarchar(25),"
                    + "sgqsgszbx nvarchar(25),"
                    + "sgqsgszby nvarchar(25));");
            stat.executeUpdate("drop table if exists zuanchang;");
            stat.executeUpdate("create table zuanchang "
                    + "(mingcheng nvarchar(200) unique, "
                    + "shendu nvarchar(25),"
                    + "xdzbx nvarchar(25) not null,"
                    + "xdzby nvarchar(25) not null,"
                    + "gongzuomian nvarchar(200),"
                    + "yanzhanxing nvarchar(25),"
                    + "kongxilv nvarchar(25),"
                    + "foreign key(gongzuomian) references gongzuomian(mingcheng));");
            stat.executeUpdate("drop table if exists zuankong;");
            stat.executeUpdate("create table zuankong "
                    + "(mingcheng nvarchar(100), "
                    + "fangwei nvarchar(25),"
                    + "qingjiao nvarchar(25),"
                    + "chengkong nvarchar(25),"
                    + "zhujiangqian nvarchar(25),"
                    + "shuiya nvarchar(25),"
                    + "kongshen nvarchar(25),"
                    + "va nvarchar(25),"
                    + "vb nvarchar(25),"
                    + "vc nvarchar(25),"
                    + "niantu nvarchar(25),"
                    + "shuini nvarchar(25),"
                    + "zhongya nvarchar(25),"
                    + "beizhu nvarchar(200),"
                    + "zuanchang nvarchar(200),"
                    + "csdjl nvarchar(25),"
                    + "foreign key(zuanchang) references zuanchang(mingcheng));");
            stat.executeUpdate("drop table if exists diceng;");
            stat.executeUpdate("create table diceng "
                    + "(mc nvarchar(100), "
                    + "jl nvarchar(25),"
                    + "hd nvarchar(25)"
                    + ");");
            stat.close();
            conn.close();
        }catch(Exception e){
        }
        
    }
//    public static void main(String args []){
//        new CreateMyDatabase("ashdf");
//    }


}
